<template>
    <div class="entrance">
        <!-- <a-button @click="login">申报</a-button>
        <a-button @click="login1">后台</a-button> -->
        <header-cont :page="loginstatus=='unlogin'?'':'login'"></header-cont>
        <div class="main">
            <div class="main_left">
                <div class="main_left_cont main_left_cont_notice">
                    <div class="cont_header">
                        <div class="name">
                            <img src="@/assets/img/tzgg_title.png" />
                            <!--<span>通知公告</span>-->
                        </div>
                        <div class="more" @click="moreFn(0)">
                            <span>更多</span>
                            <img src="@/assets/img/more.png" />
                        </div>
                    </div>
                    <ul class="cont_list">
                        <li @click="viewDetail(item.id)" class="cont_li" v-for="(item, index) in dataList" :key="index">
                            <span class="notice_title">{{item.tzggZbt}}</span>
                            <span class="notice_date">{{item.createTime}}</span>
                        </li>
                    </ul>
                </div>
                <div class="main_left_cont main_left_cont_ziliao">
                    <div class="cont_header">
                        <div class="name">
                            <img src="@/assets/img/zlzx_title.png" />
                            <!--<span>资料中心</span>-->
                        </div>
                        <div class="more" @click="moreFn(1)">
                            <span>更多</span>
                            <img src="@/assets/img/more.png" />
                        </div>
                    </div>
                    <ul class="cont_list">
                        <li class="cont_li" @click="downloadZl(item.filePath, item.zlMc)"
                            v-for="(item, index) in zlList" :key="index">
                            <span class="notice_title">{{item.zlMc}}</span>
                            <!--
                            <span class="notice_date">{{item.createTime}}</span>
                            -->
                        </li>
                    </ul>
                </div>
            </div>
            <div class="main_right">
                <div class="main_right_cont">
                    <div class="enter_tit">成果申报</div>
					<div class="enter_cont">
            			<ul>
							<li @click="handleResult(item.fl_bh, item.fl_mc, item)" v-for="(item, index) in cxjsbList" :key="index" :class="['pointer',index==0?'technology':index==1?'administration':index==2?'information':index==3?'standard':index==4?'patent':'']">
								<div class="port_tit">{{ item.fl_mc }}</div>
								<div class="port_time">
									<p>申报开始时间：{{ item.is_valid === 'Y' ? item.sb_kssj.slice(0,10) : '待定' }}</p>
									<p>申报结束时间：{{ item.is_valid === 'Y' ? item.sb_jzsj.slice(0,10) : '待定' }}</p>
								</div>
							</li>
						</ul>
					</div>
                </div>
            </div>
        </div>
        <footer-cont></footer-cont>
    </div>
</template>

<script>
import headerCont from '@/views/declarationSystem/common/header-login';
import footerCont from '@/views/declarationSystem/common/footer';
import {
    cxjsbPageList,
    sysCxjZlList,
    sysCxjFlCxjsbList,
    sysCxjZlDownload,
    cxjsbCheckFlSbsj
} from '@/api/shenbao';
export default {
    name: 'Entrance',
    components: {
        headerCont,
        footerCont,
    },
    data() {
        return {
            loginstatus: 'unlogin',
            dataList: [],
            zlList: [],
            cxjsbList: [],
        }
    },
    mounted() {
        var islogin = sessionStorage.getItem('islogin');
        if (islogin == '1') {
            this.loginstatus = 'login';
        } else {
            var shenbao_phoneNumber = localStorage.getItem('shenbao_phoneNumber');
            var shenbao_passWord = localStorage.getItem('shenbao_passWord');
            if (shenbao_phoneNumber && shenbao_passWord) {
                this.codephone = shenbao_phoneNumber;
                this.codepwd = shenbao_passWord;
                this.checked = true;
            }
            this.loginstatus = 'unlogin';
        }
        this.getSysCxjFlCxjsbList();
        this.getList();
        this.getZlList();
    },
    methods: {
        // 专家登录
        handelZjKjcxj() {
            // this.$router.push('/shenbao/exportLogin')
            window.open("https://cxj.cec.org.cn/user/zj", '_blank')
        },
        // 职工创新奖登录【专家】
        handelZgZjcxj() {
            // 申报登录入口
            window.open("https://zgcgps.cec.org.cn", '_blank')
        },
        handelKjcxj() {
            this.$router.push('/shenbao/login')
        },
        // 职工创新奖登录
        handelZgcxj() {
            //this.$router.push('/user/login')
            window.open("https://zgcg.cec.org.cn", '_blank')
        },
        // 推荐单位 - 电力科技创新奖登录
        handelZjKjcxj1() {
            window.open("https://cxj.cec.org.cn/user/tjdw", '_blank')
        },
        // 推荐单位 - 电力职工技术创新奖登录
        handelZgZjcxj1() {
            window.open("https://zgcgps.cec.org.cn", '_blank')
        },
        moreFn(ind) {
            this.$router.push('/shenbao/articleList?ind=' + ind)
        },
        // 获取申报列表
        getList() {
            cxjsbPageList().then(res => {
                if (res.data.success) {
                    this.dataList = res.data.result.records;
                }
            })
        },
        // 获取资料中心列表
        getZlList() {
            sysCxjZlList().then(res => {
                if (res.data.success) {
                    this.zlList = res.data.result.records;
                }
            })
        },
        // 跳转详情
        viewDetail(id) {
            this.$router.push({
                path: '/shenbao/innovationAwardNotice',
                query: {
                    id
                }
            })
        },
        downloadZl(url, zlMc) {
            let that = this;
            let fileGs = url.split('.');
            sysCxjZlDownload(url).then(res => {
                that.downfn(zlMc, res, fileGs[1]);
            })
        },
        downfn(title, res, fileGs) {
            const data = res.data;
            const url = window.URL.createObjectURL(new Blob([data], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            }))
            // const url = window.URL.createObjectURL(new Blob([data], {type: "application/octet-stream"}))
            const link = document.createElement('a')
            link.style.display = 'none'
            link.href = url;
            link.setAttribute('download', title + '.' + fileGs)
            document.body.appendChild(link)
            link.click()
            document.body.removeChild(link)
        },
        /* 优化开始 */
        getSysCxjFlCxjsbList() {
            sysCxjFlCxjsbList().then(res => {
                let data = res.data;
                if (data.success) {
                    this.cxjsbList = data.result;
                }
            }).catch(err => {
                sessionStorage.clear();
                this.loginstatus = 'unlogin';
            })
        },
        handleResult(id, fl_mc, item){
            let self = this;
            self.fl_bh = id;
            self.fl_mc = fl_mc;
            self.zl_time = item.sbnd;
            if (id == '61') {
                window.open("https://zgcg.cec.org.cn/", '_blank')
            } else {
                if (this.loginstatus === 'unlogin') {
                    this.$router.push('/shenbao/login')
                } else {
                    self.$confirm({
                        title: `您当前选择的是${fl_mc}，请谨慎选择申报类别，一经确定后类别无法更改！`,
                        onOk() {
                            cxjsbCheckFlSbsj({
                                fl_bh: id
                            }).then(res=>{
                                let data = res.data;
                                if (data.success){
                                    if (data.result) {
                                        self.achievementsFlag = !self.achievementsFlag;
                                    } else {
                                        self.$message.warning('当前日期不在申报范围内');
                                    }
                                } else {
                                    self.$message.warning(data.message);
                                }
                            })
                        },
                        onCancel() {
                            console.log('Cancel');
                        },
                        class: 'test',
                    });
                }
            }
        },
    }
}
</script>

<style scoped lang='less'>
    .entrance {
        width: 100%;
        background-color: #F7F7F7;

        // display: flex;
        // flex-direction: column;
        .main {
            width: 1210px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            margin-top: 20px;
        }

        .main_left {
            width: 685px;
        }

        .cont_header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #EEEEEE;
            padding-left: 30px;
            padding-right: 32px;
            box-sizing: border-box;
            height: 52px;

            .name {
                height: 100%;
                display: flex;
                align-items: center;
                border-bottom: 2px solid #2381D6;

                span {
                    margin-left: 11px;
                    font-size: 20px;
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                    font-weight: bold;
                    color: #333333;
                    line-height: 22px;
                }
            }

            .more {
                cursor: pointer;
                display: flex;
                align-items: center;

                span {
                    margin-right: 8px;
                    font-size: 16px;
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                    color: #006DC0;
                    line-height: 22px;
                }
            }
        }

        .main_left_cont {
            width: 685px;
            background: #FFFFFF;

            &.main_left_cont_notice {
                height: 258px;
            }

            &.main_left_cont_ziliao {
                height: 258px;
                margin-top: 20px;
            }

            &.main_left_cont_huojiang {
                height: 220px;
                margin-top: 20px;
            }

            .cont_list {
                padding-left: 18px;
                padding-right: 32px;
                box-sizing: border-box;
                height: 200px;
                overflow: hidden;

                .cont_li {
                    height: 48px;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    border-bottom: 1px solid #EEEEEE;
                    cursor: pointer;

                    .notice_title {
                        font-size: 16px;
                        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                        color: #4C5F82;
                        line-height: 22px;
                    }

                    .notice_date {
                        height: 22px;
                        font-size: 16px;
                        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                        color: #4B5F82;
                        line-height: 22px;
                    }
                }
            }

            .search_cont {
                .search_input {
                    display: flex;
                    align-items: center;
                    padding-left: 27px;
                    padding-right: 33px;
                    margin-top: 20px;

                    .input_li {
                        width: 195px;
                        height: 50px;
                        border-radius: 4px;
                        position: relative;

                        img {
                            position: absolute;
                            top: 16px;
                            left: 15px;
                        }

                        input {
                            width: 100%;
                            height: 100%;
                            text-indent: 23px;
                            border: 1px solid #ECEBEB;
                        }

                        &:nth-of-type(1) {
                            margin-right: 20px;
                        }

                        &:nth-of-type(2) {
                            margin-right: 20px;
                        }
                    }
                }

                .search_btn {
                    width: 160px;
                    height: 46px;
                    background: linear-gradient(90deg, #3D9CED 0%, #1A60C7 99%, #1A60C7 100%);
                    border-radius: 5px;
                    font-size: 22px;
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                    color: #FFFFFF;
                    line-height: 46px;
                    text-align: center;
                    margin: 20px auto 0;
                    cursor: pointer;
                }
            }
        }

        .main_right {
            width: 506px;

            .main_right_cont {
                width: 506px;
                height: 536px;
		        padding: 0 31px 0 37px;
                background: #FFFFFF;

                .ant-tabs-tab {
                    font-size: 20px;
                }

                &.main_right_cont_login {
                    height: 536px;
                    padding: 0 36px;
                    box-sizing: border-box;
                }
                &.main_right_cont_enter {
                    height: 536px;
                    padding: 0 31px 0 37px;
                    box-sizing: border-box;
                }

                &.main_right_cont_set {
                    height: 220px;
                    margin-top: 20px;
                }
            }
        }

        .enter_tit {
            line-height: 48px;
            padding-top: 20px;
            color: #0a4174;
            font-size: 30px;

            span {
                font-size: 30px;

                &:nth-child(1) {
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                    font-weight: 500;
                }

                &:last-child {
                    margin-left: 20px;
                    cursor: pointer;
                }
            }
        }

        .sbrk {
            width: 100%;
            height: auto;
            justify-content: space-between;
            margin-left: 50px;

            li {
                position: relative;
                width: 400px;
                height: 140px;
                background-color: #2680eb;
                border-radius: 15px;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
                margin-top: 40px;
                margin-bottom: 60px;

                &:nth-child(1) {
                    // background: #2680eb;
                    background: url('../../../assets/img/bg2.png') no-repeat;
                    background-size: auto 100%;
                }

                &:nth-child(2) {
                    background: url('../../../assets/img/bg1.png') no-repeat;
                    background-size: auto 100%;
                }

                b {
                    text-align: center;
                    font-size: 30px;
                    font-weight: normal;
                    color: #ffffff;
                    padding-right: 60px;
                    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
                }

                img {
                    width: 80px;
                    height: 80px;
                    position: absolute;
                    right: 20px;
                    top: 32px;
                }
            }
        }

        .lineTitle {
            width: 272px;
            height: 29px;
            display: flex;
            align-items: center;
            margin: 63px auto 0;

            .line {
                width: 68px;
                height: 1px;
                background: #2680eb;
            }

            b {
                display: inline-block;
                width: 136px;
                text-align: center;
                font-size: 30px;
                color: #333;
            }
        }

        .cont {
            margin-top: 42px;
            margin-bottom: 60px;
            width: 100%;
            height: 249px;
            border-radius: 15px;
            border: solid 1px #e5e5e5;
            padding: 36px 27px;

            h2 {
                color: #333;
            }

            p {
                color: #666;
            }
        }
    }


    
	.enter_cont {
		margin-top: 22px;
		ul {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			margin-bottom:0;
			li {
				width: 213px;
				height: 130px;
				border-radius: 5px;
				opacity: 0.9;
				padding-top: 20px;
				padding-left: 20px;
				padding-right: 20px;
				box-sizing: border-box;
				margin-bottom: 12px;
				.port_tit {
					height: 28px;
					font-size: 20px;
					font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 28px;
				}
				.port_time {
					margin-top: 19px;
					p {
						height: 17px;
						font-size: 12px;
						font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
						font-weight: 400;
						color: #FFFFFF;
						line-height: 17px;
					}
				}
				&.technology {
					background: #0291FE;
				}
				&.administration {
					background: #FF8E75;
				}
				&.information {
					background: #5E5DF8;
				}
				&.standard {
					background: #30D499;
				}
			}
		}
		.patent {
			width: 438px;
			height: 130px;
			background: #FAB81E;
			border-radius: 5px;
			opacity: 0.9;
			padding-top: 20px;
			padding-left: 20px;
			padding-right: 36px;
            box-sizing: border-box;
            .port_time {
                display: flex;
                justify-content: space-between;
            }
			.patent_tit {
				height: 28px;
				font-size: 20px;
				font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 28px;
			}
			.patent_time {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 20px;
				p {
					height: 17px;
					font-size: 12px;
					font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 17px;
				}
			}
		}
	}
</style>